package com.feiyu.simplesort;

/**
 * 选择排序
 *
 * @Author nanshouxiao@teacher.com.cn
 * @Date 2017-10-26 16:53
 */
public class SelectSort extends BaseSort{


    @Override
    public int[] sort(int[] array) {
        for (int i = 0; i < array.length - 1; i++) {
            int minIntIndex = i;
            for (int j = i + 1; j < array.length; j++) {
                if (array[minIntIndex] > array[j]) {
                    minIntIndex = j;
                }
            }
            if (minIntIndex != i) {
                int temp = array[i];
                array[i] = array[minIntIndex];
                array[minIntIndex] = temp;
            }

        }
        return array;
    }
}
